package CACA;

import java.util.ArrayList;

public class ItemColumn  {
	Item item;
	protected ArrayList<Integer> instances;
	ItemColumn(int a,int v)
	{
		item = new Item(a, v);
		instances = new ArrayList<Integer>();
	}
	

	public int count()
	{
		return instances.size();
	}
	static public ArrayList<Integer> intersect(ArrayList<Integer> a1, ArrayList<Integer> a2)
	{
		ArrayList<Integer> intersectInstances = new ArrayList<Integer>();
		int k1=0;
		int k2=0;
		while(k1<a1.size() && k2<a2.size())
		{
			int n1 =  a1.get(k1);
			int n2 = a2.get(k2);
			if(n1 == n2)
			{
				intersectInstances.add(n1);
				k1++;
				k2++;
			}
			else if(n1 < n2)
			{
				k1++;
			}
			else
			{
				k2++;
			}
		}
		
		return intersectInstances;
	}
	public ArrayList<Integer> intersect(ItemColumn col)
	{
		return intersect(instances, col.instances);
	}
	public ArrayList<Integer> intersect(ArrayList<Integer> a)
	{
		return intersect(instances, a);
	}
	
}
